/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Controllers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author BENSON
 */
public class ControllerAdminLogin {
    /**
     * variables and views declarations
     */
    
    Views.AdminLogin adminLogin;
    ActionListener actionListener;
    Model.MainModel model;
    /**
     * Default Constructor
     */
    public ControllerAdminLogin( ){
        adminLogin = new Views.AdminLogin();
        adminLogin.setVisible(true);
         model=new Model.MainModel();
    }
     
   
    /**
     * Method to get source of button clicked using action listener
     */
    
public void control(){        
        actionListener = new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent actionEvent) {  
                  if(actionEvent.getSource()==adminLogin.getALoginBtn()){
                        if((adminLogin.getAUsername().getText().equals("visitor"))&&(adminLogin.getAPassword().getText().equals("visitor"))){
                    ControllerAdminHomepage adminHomepage= new ControllerAdminHomepage();  
                    adminHomepage.control();
                    adminLogin.setVisible(false);
                }
                        model.showAdmin(adminLogin);
                  }
                  if(actionEvent.getSource()==adminLogin.getSignUpBtn()){
                      ControllerAddAdmin addA= new ControllerAddAdmin();
                      addA.control();
                  }                     
              }
              
        };                
        adminLogin.getALoginBtn().addActionListener(actionListener);
        adminLogin.getSignUpBtn().addActionListener(actionListener);
}  
    
}
